#pragma once

#include "Observer.h"
#include "IComponentSystem.h"
#include "IEventListener.h"
#include "IMouseListener.h"

class CameraComponent;

class CameraSystem : public ZeEngine::IComponentSystem, public IMouseListener, public ZeEngine::IEventListener
{
public:
	CameraSystem();
	~CameraSystem();

	//Component System
    virtual bool Init(ZeEngine::GameEngine& gameEngine) override;
    virtual void PreUpdate(ZeEngine::GameEngine& gameEngine) override;
    virtual bool Update(ZeEngine::GameEngine& gameEngine) override;
    virtual void PostUpdate(ZeEngine::GameEngine& gameEngine) override;
    virtual void Destroy(ZeEngine::GameEngine& gameEngine) override;

    //MouseListener
    virtual bool OnMouseMoved(const Vector2D<s32>& absolute, const Vector2D<s32>& relative) override;
    virtual bool OnMouseButtonPressed(const Vector2D<s32>& absolute, s32 button) override;
    virtual bool OnMouseButtonReleased(const Vector2D<s32>& absolute, s32 button) override;

    //IEventListener
    virtual bool HandleEvent(const Event& evt) override;

	const Vector2D<s32>& GetCameraPosition(bool fTop);

private:
    void UpdateBaseCamera();

private:
    bool             m_fDragging;
    Vector2D<f32>    m_fMouseRelative;

    Vector2D<u32>    m_resolution;

    //Gaulem Camera
    Entity*          m_pGaulemCamera;
    CameraComponent* m_pGaulemCameraComponent;

    //Base Camera
    Entity*          m_pBaseCamera;
    CameraComponent* m_pBaseCameraComponent;

	Entity* m_pGaulemEntity;
};
